package com.tfjybj.itoo.teach.provider.facade;

import org.apache.dubbo.config.annotation.Service;
import com.dmsdbj.itoo.tool.business.ItooResult;
import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.teach.FacadeApi.StudentApi;
import com.tfjybj.itoo.teach.entity.StudentEntity;
import com.tfjybj.itoo.teach.model.StudentModel;
import com.tfjybj.itoo.teach.provider.service.StudentService;
import org.apache.ibatis.annotations.Param;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by QZS on 2019/4/18.
 */
@Service
@org.springframework.stereotype.Service
public class StudentFacade implements StudentApi {
    @Resource
    StudentService studentService;

    /**
     * 根据姓名和学号模糊查询student
     *
     * @param name 姓名
     * @param code 学号
     * @return 模糊查询的student集合
     * @author 郄子硕
     * @since 2.0.0 2018-11-17 21:27:48
     */
    @Override
    public PageInfo<StudentModel> queryLikeNameAndCode(String name, String code, Integer pageNo, Integer pageSize) {
        return studentService.queryLikeNameAndCode(name, code, pageNo, pageSize);
    }

    @Override
    public List<StudentModel> queryStudentByCode(String code) {
        return studentService.queryStudentByCode(code);
    }

    @Override
    public PageInfo<StudentModel> queryStudentByByClassIds(@Param("list") List<String> ids, Integer pageNum, Integer pageSize) {
        return studentService.queryStudentByByClassIds(ids, pageNum, pageSize);
    }


    /**
     * 添加
     *
     * @param studentEntity StudentEntity
     * @return 添加的结果
     * @author 杨江涛
     * @since 2.0.0 2018-11-15 10:35:56
     */
    @Override
    public boolean save(StudentEntity studentEntity) {
        return studentService.save(studentEntity);
    }

    /**
     * 删除
     *
     * @param id 主键id
     * @return ItooResult 是否删除成功
     * @author 杨江涛
     * @since 2.0.0 2018-11-15 10:35:56
     */
    @Override
    public boolean removeById(String id) {
        return studentService.removeById(id);
    }

    /**
     * 批量删除
     *
     * @param ids ids
     * @return ItooResult 批量删除是否成功结果
     * @author 杨江涛
     * @since 2.0.0 2018-11-15 10:35:56
     */
    @Override
    public boolean removeByIds(List<String> ids) {
        return studentService.removeByIds(ids);
    }

    /**
     * 修改
     *
     * @param studentEntity StudentModel
     * @return 修改后的结果
     * @author 杨江涛
     * @since 2.0.0 2018-11-15 10:35:56
     */
    @Override
    public boolean updateById(StudentEntity studentEntity) {
        return studentService.updateById(studentEntity);
    }

    /**
     * 根据id查找Student
     *
     * @param id 主键id
     * @author 杨江涛
     * @since 2.0.0 2018-11-15 10:35:56
     */
    @Override
    public StudentEntity getById(String id) {
        return studentService.getById(id);
    }

    /**
     * 分页查询所有Student
     *
     * @param pageNo   页码
     * @param pageSize 每页条数
     * @author 杨江涛
     * @since 2.0.0 2018-11-15 10:35:56
     */
    @Override
    public PageInfo<StudentEntity> queryPageAll(Integer pageNo, Integer pageSize) {
        return studentService.queryPageAll(pageNo, pageSize);
    }

    /**
     * 根据姓名模糊查询student
     *
     * @param name     姓名
     * @param pageNo   页码
     * @param pageSize 页数
     * @return 模糊查询的student
     * @author 杨江涛
     * @since 2.0.0 2018-11-15 10:35:56
     */
    @Override
    public ItooResult queryByLikeName(String name, Integer pageNo, Integer pageSize) {
        PageInfo<StudentEntity> staffList = studentService.queryByLikeName(name, pageNo, pageSize);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", staffList);
    }
}
